package io.renren.modules.sys.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.AdvertDao;
import io.renren.modules.sys.entity.AdvertEntity;
import io.renren.modules.sys.service.AdvertService;


@Service("advertService")
public class AdvertServiceImpl extends ServiceImpl<AdvertDao, AdvertEntity> implements AdvertService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = (String)params.get("name");
        String type = (String)params.get("type");

        IPage<AdvertEntity> page = this.page(
                new Query<AdvertEntity>().getPage(params),
                new QueryWrapper<AdvertEntity>().like(StringUtils.isNotBlank(name),"adName",name)
                        .eq(StringUtils.isNotBlank(type),"statu",type)
        );

        return new PageUtils(page);
    }

}
